import type { ChartRecord, WsRes } from "@/types"
import { ElMessage } from 'element-plus'
import type { Ref } from "vue"
import { useLocalUserStore } from "@/stores/localUser"


const SUCCESS_CODE = '200'

export const reqSuccess = (code:string) => {
    return code === SUCCESS_CODE
}

const  NEW_FRIEND_ADVICE = "friendAdvice";
const NEW_CHART_ADVICE = "chartAdvice";

export const handleWsRes = (data:WsRes,currentCharts:Ref<Array<ChartRecord>>,me:(msg:string,from:string,to:string)=>void) => {
    if(data.needAdvice) {
        ElMessage({
            message: data.message,
            type: 'success',
          })
    }
    console.log(data.payload.from);
    console.log(data.payload.to);
    console.log(data.payload.content);
    
    me(data.payload.content,data.payload.from,data.payload.to)
    // switch(data.type) {
    //     case NEW_CHART_ADVICE: processNewChart()
    // }
}

export const chartLeftOrRight = (localUser:string,fromUser:string) => {
    return localUser == fromUser
}